package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookPublisher;
import com.pgybook.db.entity.domain.BookPublisherEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookPublisherMapper {
    int countByExample(BookPublisherEx example);

    int deleteByExample(BookPublisherEx example);

    @Delete({
            "delete from bookpublisher",
            "where PUBLISHERID = #{publisherid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer publisherid);

    @Insert({
            "insert into bookpublisher (NAME, ADDRESS, ",
            "CONTACT, PHONE, ",
            "ISBNCODE, STATUS, ",
            "DESCRIPTION, WEBSITE, ",
            "POSTCODE, CRTTIME, ",
            "CRTSTAFF, UPDTIME, ",
            "UPDSTAFF)",
            "values (#{name,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ",
            "#{contact,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
            "#{isbncode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
            "#{description,jdbcType=VARCHAR}, #{website,jdbcType=VARCHAR}, ",
            "#{postcode,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{crtstaff,jdbcType=INTEGER}, #{updtime,jdbcType=TIMESTAMP}, ",
            "#{updstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "publisherid", before = false, resultType = Integer.class)
    int insert(BookPublisher record);

    int insertSelective(BookPublisher record);

    List<BookPublisher> selectByExample(BookPublisherEx example);

    @Select({
            "select",
            "PUBLISHERID, NAME, ADDRESS, CONTACT, PHONE, ISBNCODE, STATUS, DESCRIPTION, WEBSITE, ",
            "POSTCODE, CRTTIME, CRTSTAFF, UPDTIME, UPDSTAFF",
            "from bookpublisher",
            "where PUBLISHERID = #{publisherid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    BookPublisher selectByPrimaryKey(Integer publisherid);

    int updateByExampleSelective(@Param("record") BookPublisher record, @Param("example") BookPublisherEx example);

    int updateByExample(@Param("record") BookPublisher record, @Param("example") BookPublisherEx example);

    int updateByPrimaryKeySelective(BookPublisher record);

    @Update({
            "update bookpublisher",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "ADDRESS = #{address,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "ISBNCODE = #{isbncode,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR},",
            "WEBSITE = #{website,jdbcType=VARCHAR},",
            "POSTCODE = #{postcode,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER}",
            "where PUBLISHERID = #{publisherid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BookPublisher record);
}
